Skip to content

feat: Improve usage limit handling and data freshness#1877

Merged
charlesvien merged 13 commits intomainfrom
04-23-billing_nits
Apr 24, 2026
Merged

feat: Improve usage limit handling and data freshness#1877
charlesvien merged 13 commits intomainfrom
04-23-billing_nits

Conversation

@charlesvien
Copy link
Copy Markdown
Member

@charlesvien charlesvien commented Apr 23, 2026

Problem

Usage limits were silently swallowed or triggered at wrong times, and billing data went stale after plan changes.

Changes

  1. Show usage limit modal on 429 rate limit instead of disconnecting the session
  2. Only trigger usage alert mid-task, skip idle and onboarding states
  3. Refetch seat and usage data on Plan & Usage tab open, poll every 30s
  4. Invalidate usage cache after plan changes so limits update immediately
  5. Handle auto-provision race by re-fetching seat instead of erroring
  6. Remove dev-mode override that force-enabled all feature flags

How did you test this?

Manually

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@charlesvien charlesvien changed the title Billing nits feat: Billing nits Apr 23, 2026
@charlesvien charlesvien marked this pull request as ready for review April 24, 2026 04:39
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 24, 2026

Prompt To Fix All With AI
This is a comment left during a code review.
Path: apps/code/src/renderer/features/billing/hooks/useUsageLimitDetection.ts
Line: 22-32

Comment:
**Idle usage-exceeded state silently dropped**

The previous code showed a modal for both active and idle states when usage was exceeded. After this change, if usage is exceeded while no session has `isPromptPending`, `hasAlertedRef.current` is never set to `true`, so the condition re-evaluates on every usage poll (now every 30 s) but never triggers anything. Users who hit their limit while idle receive no proactive notification — they'll only see the modal if they subsequently start a prompt that bounces back a 429 and gets caught in `service.ts`.

If this is intentional (prefer reactive detection over proactive polling for the idle case), a comment here would help future maintainers understand why the `show("idle")` path was removed entirely.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: apps/code/src/shared/errors.ts
Line: 23-27

Comment:
**Bare `"429"` substring pattern is overly broad**

`includesAny` does a case-insensitive `.includes()` check, so any error message containing the three characters `429` (e.g., `"session not found after 429 retries"`, a port number, a token ID, etc.) will be classified as a rate-limit error and suppress fatal-error recovery in `isFatalSessionError`. Prefer matching on the full HTTP status line or a more anchored pattern like `" 429 "` / `"status 429"` to reduce the risk of false positives.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "Only show usage modal mid-task not on id..." | Re-trigger Greptile

Comment thread apps/code/src/shared/errors.ts
@charlesvien charlesvien enabled auto-merge (squash) April 24, 2026 04:45
@charlesvien charlesvien changed the title feat: Billing nits feat: Improve usage limit handling and data freshness Apr 24, 2026
@charlesvien charlesvien disabled auto-merge April 24, 2026 15:13
@charlesvien charlesvien merged commit de71216 into main Apr 24, 2026
16 checks passed
@charlesvien charlesvien deleted the 04-23-billing_nits branch April 24, 2026 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants